package com.xnj.file_buffer_stream_demo;

import java.io.*;

// 字节输入输出缓冲流
public class FileByteBufferTest {
    public static void main(String[] args)  {
        try (
                FileInputStream is = new FileInputStream("src/疯狂星期四.png");
                // 1.1 创建字节输入缓存流
                BufferedInputStream bis = new BufferedInputStream(is);

                FileOutputStream os = new FileOutputStream("src/疯狂星期四copy.png");
                //2.2 创建字节输出缓存流
                BufferedOutputStream bos = new BufferedOutputStream(os);
                ){

            byte[] buffer = new byte[1024];
            int len;
            while ((len = bis.read(buffer)) != -1){

                bos.write(buffer, 0, len);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
